/*
 * AGENT SHERPA
 *  
 * Assignement 2 of the Agent Oriented Software Engineering Course
 * M.Sc. in Advanced Software Engineering (Part-time)
 * University College Dublin www.ucd.ie
 *
 * Copyright (c) 2007 Chris Walsh, Aidan Morrisy and Iain Hull.
 * All rights reserved.
 */

package org.agentsherpa;

import com.agentfactory.platform.interfaces.Actuator;
import com.agentfactory.platform.logic.FOS;

public class MergeMapMessageActuator extends Actuator {
	public boolean act(FOS action) {
		try {
			ControlAgentModule module = getControlModule();
			String agent = action.argAt(0).toString();
			String data = action.argAt(1).toString();

			module.mapMerge(agent, MapUtil.stripQuotes(data));
		} catch (ActuatorException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	private ControlAgentModule getControlModule() throws ActuatorException {
		ControlAgentModule module = (ControlAgentModule) getModuleByName("controlagentmodule");
		if (module == null) {
			throw new ActuatorException("Cannot access LocationModule");
		}
		return module;
	}
}
